package dialoguebox;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * JOptionPane .自带的消息提示框
 * JOptionPane.showMessageDialog (),消息提示框
 * JOptionPane.showConfirmDialog()，确认提示框
 * JOptionPane.showInputDialog() » 输入提示框
 * 其中，show*。均为工具方法，即静态方法（static ）
 */
public class DialogueBox {
    public static void main(String[] args) {
        JFrame jFrame = new JFrame("java-swing");
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrame.setSize(400,300);
        jFrame.setVisible(true);


        JPanel jPanel = new JPanel();
        jFrame.setContentPane(jPanel);
        JButton jButton = new JButton("DialogueBox");
        jPanel.add(jButton);

        //对jButton添加ActionListener
        jButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int select = JOptionPane.showConfirmDialog(jButton,"是否确认删除？","确认",JOptionPane.YES_NO_OPTION);

                JOptionPane.showMessageDialog(jFrame,"DialogueBox操作已完成");

            }
        });

    }
}
